package com.mayn.util;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jfinal.plugin.activerecord.Db;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class FetchUtils {
	private static final Logger LOG = LoggerFactory.getLogger(FetchUtils.class);
	/**
	 * 抓取日期
	 */
	public static String date = "";
	
	/**
	 * 抓取日期	
	 */
	public static Date date_fmt = null;
	/**
	 * 店铺
	 */
	public static int ShopId = 5;


	public static List<Map<String,Object>> InsertToMap(JSONArray jsonArray){

		//创建传递map
		List<Map<String, Object>>  listmap =  new ArrayList<Map<String, Object>>();
		//循环插入数据
		for (int i = 0; i < jsonArray.size(); i++) {
			Map<String, Object> map = new HashMap<String,Object>();
			//取出一行数据
			JSONObject jsonObject = jsonArray.getJSONObject(i);
//			LOG.info("一行数据：campaignId->"+jsonObject.get("campaignId").toString());
			//JSONObject 转map
			Iterator<?> it = jsonObject.keys();
			//取出每条数据的键值对
			while (it.hasNext()) {
				String key = String.valueOf(it.next());
				//LOG.info("KEY:"+key);
				Object value = jsonObject.get(key);
				//LOG.info("\r\nVALUE:"+value);
				map.put(key, value);
			}
			listmap.add(i, map);
		}
			return listmap ;
	}
	

	public static List<Map<String,Object>> InsertToMap(JSONObject json){
	//创建传递map
	List<Map<String, Object>>  listmap =  new ArrayList<Map<String, Object>>();
	//循环插入数据
	for (int i = 0; i < json.size(); i++) {
		Map<String, Object> map = new HashMap<String,Object>();
		//取出一行数据
		JSONObject jsonObject = (JSONObject) json.get("dsr");
//		LOG.info("一行数据：campaignId->"+jsonObject.get("campaignId").toString());
		//JSONObject 转map
		Iterator<?> it = jsonObject.keys();
		//取出每条数据的键值对
		while (it.hasNext()) {
			String key = String.valueOf(it.next());
			LOG.info("KEY:"+key);
			Object value = jsonObject.get(key);
			LOG.info("\r\nVALUE:"+value);
			map.put(key, value);
		}
		listmap.add(i, map);
	}
		return listmap ;
	}
	
	/**
	 * 保存生意参谋数据shop_hot_product表
	 * @para
	 * @author 梁志渊
	 * @return 
	 */
	public static boolean savedata_sycm(Map<String, Object>  map,int shopId,String date){
		
		try {

			int orderNum = 0;//排名ID
			Date shpDate = DateUtil.stringFmtToDate(date,"yyyy-MM-dd");//suf抓取时间
			
			double payOrdCnt =0.0; 
			double payByrRateIndex =0.0;
			double tradeIndexCrc =0.0;
			double  pvIndex =0.0;
			double searchIndex =0.0;
		    boolean mallItem ;
		    String   itemPicUrl = "";
		    double itemPrice =0.0;
		    String shopName = "";
		    String itemUrl =""; 
		    String itemId = "";
		    String shopUrl = "";
		    String sameGoodUrl  = "";
		    String itemTitle = ""; 
			
			Date shpCreateDatetime =DateUtil.dateToTimestamp(new Date()  ) ;//创建时间
			int 	shpCreateBy = 1;//创建人
			Date shpModifyDatetime = DateUtil.dateToTimestamp(new Date()) ;//修改时间
			int    shpModifyBy	= 1;//修改人
			int    shpDel = 0;		 //未删除
			
			if( StringUtil.isBlank(map.get("orderNum"))){
				orderNum = 0;
			}else{
				orderNum = (int) map.get("orderNum");
			}
			if( StringUtil.isBlank(map.get("payOrdCnt"))){
				payOrdCnt = 0.0;
			}else {
				payOrdCnt = (double) map.get("payOrdCnt");
			}
			
			if( StringUtil.isBlank(map.get("payByrRateIndex"))){
				LOG.info("空值!------>payByrRateIndex");
			}else {
				payByrRateIndex = (double) map.get("payByrRateIndex");
			}
			
			if( StringUtil.isBlank(map.get("tradeIndexCrc"))){
				LOG.info("空值!------>tradeIndexCrc");
			}else{
				tradeIndexCrc = (double) map.get("tradeIndexCrc");
			}
			if( StringUtil.isBlank(map.get("pvIndex"))){
				LOG.info("空值!------>pvIndex");
			}else{
				pvIndex = (double) map.get("pvIndex");
			}
			if( StringUtil.isBlank(map.get("searchIndex"))){
				LOG.info("空值!------>searchIndex");
			}else{
				searchIndex = (double) map.get("searchIndex");
			}
			if( StringUtil.isBlank(map.get("mallItem"))){
				LOG.info("空值!------>mallItem");
				mallItem = false;
			}else{
				mallItem = (boolean) map.get("mallItem");
			}
			
		    if(StringUtil.isBlank(itemPicUrl)){
		    	itemPicUrl = "";
		    }else{
		    	itemPicUrl =  map.get("itemPicUrl").toString();
		    }
		    
		    if(StringUtil.isBlank(itemPrice)){
		    	itemPrice = 0.0;
		    }else{
		    	itemPrice = (double) map.get("itemPrice");
		    }
		    
			if(StringUtil.isBlank(map.get("shopName"))){
				shopName = "";
			}else {
				shopName = map.get("shopName").toString();
			}
			
			if(StringUtil.isBlank(map.get("itemUrl"))){
				itemUrl = "";
			}else {
				itemUrl =   map.get("itemUrl").toString();
			}
			
			if(StringUtil.isBlank(map.get("itemId"))){
				itemId = "";
			}else {
				itemId = map.get("itemId").toString();
			}
			
			if(StringUtil.isBlank(map.get("shopUrl"))){
				shopUrl = "";
			}else {
				shopUrl= map.get("shopUrl").toString();
			}
			
			if(StringUtil.isBlank(map.get("sameGoodUrl"))){
				sameGoodUrl = "";
			}else {
				sameGoodUrl= map.get("sameGoodUrl").toString();
			}
			
			if(StringUtil.isBlank(map.get("itemTitle"))){
				itemTitle = "";
			}else {
				itemTitle= map.get("itemTitle").toString();
			}
			
	 
			String sql = "INSERT INTO `db-mayn-erp-prd`.`shop_hot_product` ( "
					+ "`SHP_DATE`,"
					+ "`SHP_SHOP_ID`,"
					+ "`SHP_ORDERNUM`, "
					+ "`SHP_PAYORDCNT`, "
					+ "`SHP_PAYBYRRATEINDEX`,"
					+ " `SHP_TRADEINDEXCRC`, "
					+ "`SHP_PVINDEX`, "
					+ "`SHP_SEARCHINDEX`,"
					+ " `SHP_MALLITEM`,"
					+ " `SHP_ITEMPICURL`, "
					+ "`SHP_ITEMPRICE`, "
					+ "`SHP_SHOPNAME`,"
					+ " `SHP_ITEMURL`,"
					+ " `SHP_ITEMID`, "
					+ "`SHP_SHOPURL`, "
					+ "`SHP_SAMEGOODURL`, "
					+ "`SHP_ITEMTITLE`,"
					+"`SHP_CREATE_DATETIME`,"
					+"`SHP_CREATE_BY`,"
					+"`SHP_MODIFY_DATETIME`,"
					+"`SHP_MODIFY_BY`,"
					+ "`SHP_DEL`)"
					
					+ " VALUES  ('" +  shpDate
					+"','" + shopId
					+"','" + orderNum
					+"','" + payOrdCnt
					+ "','"+ payByrRateIndex
					+ "','"+ tradeIndexCrc
					+ "','"+ pvIndex
					+ "','"+ searchIndex
					
					+ "','"+ mallItem
					
					+ "','"+ itemPicUrl
					+ "','"+ itemPrice
					+ "','"+ shopName
					+ "','"+ itemUrl
					+ "','"+ itemId
					+ "','"+ shopUrl
					+ "','"+ sameGoodUrl
					+ "','"+ itemTitle
					+ "','"+ shpCreateDatetime
					+ "','"+ shpCreateBy
					+ "','"+ shpModifyDatetime
					+ "','"+ shpModifyBy
					+ "','"+ shpDel
					+ "');";
			
			 LOG.info("保存数据的ID --->:orderNum:"+orderNum);
			 LOG.info("保存数据的时间--->"+shpDate);
			 LOG.info("保存数据的 payOrdCnt--->"+payOrdCnt);
			if( Db.use("erp").update(sql) > 0){
				LOG.info("update-->插入成功！");
				return true;
			}else {
				LOG.info("插入失败！");
				return false;
			}
		} catch (Exception e) {
			e.printStackTrace();
			String mailText = "生意参谋数据抓取失败"+"\r\n"+Thread.currentThread().getStackTrace()[1].getMethodName() + " Exception,Msg=" + e.getMessage();
		    SendCloudMailUtil.sendMailCode(mailText,"service@mayn.com.cn");
		}

		return false;
	}
	
	/**
	 * 淘宝客数据
	 * @author 梁志渊
	 * @param ShopId 店铺ID
	 * @param sufdate 日期
	 * @return
	 */
	public static Boolean savedata_tbk(Map<String, Object>  map,int ShopId,String sufdate){

		try {

			int campaignId = 0;//计划ID'
			Date sufDate = DateUtil.stringFmtToDate(sufdate,"yyyy-MM-dd");//suf抓取时间
			int shopId = ShopId;//店铺ID
			String campaignName = "";//计划名称
			Double commissionRate = 0.0;//佣金率
			String tbTradeParentId = "";//淘宝交易父单号
			String tbTradeId = "";			//淘宝交易单号
			String tbAuctionTitle ="";		//淘宝拍卖商品名称
			String earningTime = "";		//收益时间
			Double tkCommissionFee = 0.0;//淘宝客佣金
			String nickname = "";				//客户昵称
			Double tkCommissionRate = 0.0;//淘宝客佣金率
			Double tbAuctionPrice = 0.0;	 //淘宝拍卖价格
			int tbAuctionNum =0;				//淘宝拍卖数量
			int tkPubId = 0;						//
			Double tbFinishTotalPrice = 0.0;//淘宝结算总金额
			Date tbTradeCreateTime =   null;//淘宝交易创建时间
			Date tbTradeFinishTime = null;//淘宝交易结束时间
			String fmtCommissionRate ="";//FMT佣金率
			String fmtCommissionFee = "";//FMT佣金
			String fmtAuctionPrice = "";		//FMT拍卖价格
			String fmtTbFinishTotalPrice = "";//FMT淘宝结算总金额
			
			Date sufCreateDatetime =DateUtil.dateToTimestamp(new Date()  ) ;//创建时间
			int 	sufCreateBy = 1;//创建人
			Date sufModifyDatetime = DateUtil.dateToTimestamp(new Date()) ;//修改时间
			int    sufModifyBy	= 1;//修改人
			int    sufDel = 0;		 //未删除
			
			if( !StringUtil.isBlank(map.get("campaignId"))){
				campaignId = (int) map.get("campaignId");
			}
			
			if( !StringUtil.isBlank(map.get("campaignName"))){
				campaignName = map.get("campaignName").toString();
			}
			
			if( !StringUtil.isBlank(map.get("commissionRate"))){
				commissionRate = (Double) map.get("commissionRate");
			}
			
			if( !StringUtil.isBlank(map.get("tbTradeParentId"))){	
				tbTradeParentId = map.get("tbTradeParentId").toString();
			}
			
			if( !StringUtil.isBlank(map.get("tbTradeId"))){	
				tbTradeId = map.get("tbTradeId").toString();
			}
			
			if( !StringUtil.isBlank(map.get("tbAuctionTitle"))){	
				tbAuctionTitle = map.get("tbAuctionTitle").toString();
			}
			
			if( !StringUtil.isBlank(map.get("earningTime"))){	
				earningTime = map.get("earningTime").toString();
			}
			
			if( !StringUtil.isBlank(map.get("tkCommissionFee"))){	
			 tkCommissionFee = (Double) map.get("tkCommissionFee");
			}
			if( !StringUtil.isBlank(map.get("nickname"))){	
			 nickname = map.get("nickname").toString().replace("'", "''");
			}
			if( !StringUtil.isBlank(map.get("tkCommissionRate"))){	
			 tkCommissionRate = (Double) map.get("tkCommissionRate");
			}
			if( !StringUtil.isBlank(map.get("tbAuctionPrice"))){
			 tbAuctionPrice = (Double) map.get("tbAuctionPrice");
			}
			
			if( !StringUtil.isBlank(map.get("tbAuctionNum"))){
			 tbAuctionNum = (int) map.get("tbAuctionNum");
			}
			if( !StringUtil.isBlank(map.get("tkPubId"))){
			 tkPubId = (int) map.get("tkPubId");
			}
			if( !StringUtil.isBlank(map.get("tbFinishTotalPrice"))){
			 tbFinishTotalPrice = (Double) map.get("tbFinishTotalPrice");
			}
			if( !StringUtil.isBlank(map.get("tbTradeCreateTime"))){
			 tbTradeCreateTime =  DateUtil.stringFmtToDate(map.get("tbTradeCreateTime").toString(),"yyyy-MM-dd");
			}
			if( !StringUtil.isBlank(map.get("tbTradeFinishTime"))){
			 tbTradeFinishTime = DateUtil.stringFmtToDate(map.get("tbTradeFinishTime").toString(),"yyyy-MM-dd");
			}
			if( !StringUtil.isBlank(map.get("fmtCommissionRate"))){
			 fmtCommissionRate = map.get("fmtCommissionRate").toString();
			}
			if( !StringUtil.isBlank(map.get("fmtCommissionFee"))){
			 fmtCommissionFee = map.get("fmtCommissionFee").toString();
			}
			if( !StringUtil.isBlank(map.get("fmtAuctionPrice"))){
			 fmtAuctionPrice = map.get("fmtAuctionPrice").toString();
			}
			if( !StringUtil.isBlank(map.get("fmtTbFinishTotalPrice"))){
			 fmtTbFinishTotalPrice = map.get("fmtTbFinishTotalPrice").toString();
			}
 
			String sql = "INSERT INTO `db-mayn-erp-prd`.`shop_union_fee` ( "
					+ "`SUF_DATE`,"
					+ "`SUF_SHOP_ID`,"
					+ "`SUF_CAMPAIGN_ID`, "
					+ "`SUF_CAMPAIGN_NAME`, "
					+ "`SUF_COMMISSION_RATE`,"
					+ " `SUF_TB_TRADE_PARENT_ID`, "
					+ "`SUF_TB_TRADEID`, "
					+ "`SUF_TB_AUCTION_TITLE`,"
					+ " `SUF_EARNING_TIME`,"
					+ " `SUF_TK_COMMISSION_FEE`, "
					+ "`SUF_NICK_NAME`, "
					+ "`SUF_TK_COMMISSION_RATE`,"
					+ " `SUF_TB_AUCTION_PRICE`,"
					+ " `SUF_TB_AUCTION_NUM`, "
					+ "`SUF_TK_PUB_ID`, "
					+ "`SUF_TB_FINISH_TOTAL_PRICE`, "
					+ "`SUF_TB_TRADE_CREATE_TIME`,"
					+ " `SUF_TB_TRADE_FINISH_TIME`, "
					+ "`SUF_FMT_COMMISSION_RATE`, "
					+ "`SUF_FMT_COMMISSION_FEE`, "
					+ "`SUF_FMT_AUCTION_PRICE`, "
					+"`SUF_FMT_TB_FINISH_TOTAL_PRICE`,"
					+"`SUF_CREATE_DATETIME`,"
					+"`SUF_CREATE_BY`,"
					+"`SUF_MODIFY_DATETIME`,"
					+"`SUF_MODIFY_BY`,"
					+ "`SUF_DEL`)"
					
					+ " VALUES  ('" +  sufDate
					+"','" + shopId
					+"','" + campaignId
					+"','" + campaignName
					+ "','"+ commissionRate
					+ "','"+ tbTradeParentId
					+ "','"+ tbTradeId
					+ "','"+ tbAuctionTitle
					+ "','"+ earningTime
					+ "','"+ tkCommissionFee
					+ "','"+ nickname
					+ "','"+ tkCommissionRate
					+ "','"+ tbAuctionPrice
					+ "','"+ tbAuctionNum
					+ "','"+ tkPubId
					+ "','"+ tbFinishTotalPrice
					+ "','"+ tbTradeCreateTime
					+ "','"+ tbTradeFinishTime
					+ "','"+ fmtCommissionRate
					+ "','"+ fmtCommissionFee
					+ "','"+ fmtAuctionPrice
					+ "','"+ fmtTbFinishTotalPrice
					+ "','"+ sufCreateDatetime
					+ "','"+ sufCreateBy
					+ "','"+ sufModifyDatetime
					+ "','"+ sufModifyBy
					+ "','"+ sufDel
					+ "');";
			
			 LOG.info("保存数据的tbTradeId--->:"+tbTradeId);
//			 LOG.info("保存数据的时间--->"+sufDate);
			 LOG.info("数据的时间:earningTime--->"+earningTime);
			if( Db.use("erp").update(sql) > 0){
				
				LOG.info("update-->插入成功！");
				return true;
			}else {
				LOG.info("插入失败！");
				return false;
			}
		} catch (Exception e) {
			e.printStackTrace();
			String mailText = "淘宝客数据抓取失败"+"\r\n"+Thread.currentThread().getStackTrace()[1].getMethodName() + " Exception,Msg=" + e.getMessage();
		    SendCloudMailUtil.sendMailCode(mailText,"service@mayn.com.cn");
		}

		return false;
	
	
	}
	/**
	 * 增加日期
	 * @param date
	 * @param day
	 * @return
	 */
	public static String addDate(String date,int day){
		Date date_fmt = DateUtil.stringFmtToDate(date, "yyyy-MM-dd");
		DateUtil.addDays(date_fmt, 1);
		date  = DateUtil.dateFmtToString(date_fmt);
		return date;
	}

/**
 * 保存单品服务分析数据
 * @param listmap
 * @param itemId 店铺ID
 * @param date 日期
 * @return
 */
	public static Boolean savedata_dar(List<Map<String, Object>> listmap, String itemId, String date) {
		
		try {
			Map<String,Object> map = new HashMap<String,Object>();
			String Dar_item_id = itemId;//排名ID

			Date darDate = DateUtil.stringFmtToDate(date,"yyyy-MM-dd");//dar抓取时间
			/**
			 * score? 为商品评分
			 * rate？为占比 
			 */
			int[] score = new int[5];
			double[] rate =  new double[5];
			Date datetime = new Date();
			Date darCreateDatetime = DateUtil.dateToTimestamp(datetime);
			//创建时间
			int 	darCreateBy = 1;//创建人
			Date darModifyDatetime =  DateUtil.dateToTimestamp(datetime);//修改时间 );
			
			int    darModifyBy	= 1;//修改人
			int    darDel = 0;		 //未删除
			
			for (int j = 0; j < listmap.size(); j++) {
				map = listmap.get(j);

				JSONObject jsonObject = new JSONObject();
				jsonObject = JSONObject.fromObject(map.get("dsr"));
				String _score = jsonObject.get("value").toString();
				String _rate = jsonObject.get("ratio").toString();
				// LOG.info(_score);
				if (StringUtil.isBlank(_score)) {
					score[j] = 0;
				} else if (StringUtil.isBlank(_rate)) {
					rate[j] = 0.0;
				} else {
					score[j] = Integer.parseInt(_score);
					rate[j] = Double.parseDouble(_rate);
				}
			}

			
	 
			String sql = "INSERT INTO `db-mayn-erp-prd`.`DsrAnalysisReview` ( "
					+ "`DAR_ITEM_ID`,"
					+ "`DAR_START_DATE`,"
					+ "`DAR_END_DATE`, "
					+ "`DAR_FIVE_SCORE`, "
					+ "`DAR_FIVE_RATE`, "
					+ "`DAR_FOUR_SCORE`, "
					+ "`DAR_FOUR_RATE`, "
					+ "`DAR_THREE_SCORE`, "
					+ "`DAR_THREE_RATE`, "
					+ "`DAR_TWO_SCORE`, "
					+ "`DAR_TWO_RATE`, "
					+ "`DAR_ONE_SCORE`, "
					+ "`DAR_ONE_RATE`, "
					+"`DAR_CREATE_DATETIME`,"
					+"`DAR_CREATE_BY`,"
					+"`DAR_MODIFY_DATETIME`,"
					+"`DAR_MODIFY_BY`,"
					+ "`DAR_DEL`)"
					
					+ " VALUES  ('" +  Dar_item_id
					+ "','"+ darDate
					+ "','"+ darDate
					+ "','"+ score[4]
					+ "','"+ rate[4]
					+ "','"+ score[3]
					+ "','"+ rate[3]
					+ "','"+ score[2]
					+ "','"+ rate[2]
					+ "','"+ score[1]
					+ "','"+ rate[1]
					+ "','"+ score[0]
					+ "','"+ rate[0]
					+ "','"+ darCreateDatetime
					+ "','"+ darCreateBy
					+ "','"+ darModifyDatetime
					+ "','"+ darModifyBy
					+ "','"+ darDel
					+ "');";
			
			 LOG.info("保存数据的ID --->:Dar_item_id:"+Dar_item_id);
			 LOG.info("保存数据的score5  --->"+score[4]);
			 LOG.info("sql-->"+sql);
			if( Db.use("erp").update(sql) > 0){
				
				LOG.info("update-->插入成功！");
				return true;
			}else {
				LOG.info("插入失败！");
				return false;
			}
		} catch (Exception e) {
			e.printStackTrace();
			String mailText = "单品服务分析数据抓取失败"+"\r\n"+Thread.currentThread().getStackTrace()[1].getMethodName() + " Exception,Msg=" + e.getMessage();
		    SendCloudMailUtil.sendMailCode(mailText,"service@mayn.com.cn");
		}

		return false;
			
	}
	/**
	 * 重点服务指标总览
	 * @param listmap
	 * @param itemId 商品ID
	 * @param date 日期
	 * @return
	 */
	public static boolean savedata_guide(Map<String, Object> map, String itemId, String date) { 
		
		try {
			String dar_guide_Item_Id = itemId;// ID

			Date darDate = DateUtil.stringFmtToDate(date,"yyyy-MM-dd");//dar抓取时间
			/**
			 * score? 为商品评分
			 * rate？为占比 
			 */
			double rfdSucQaRate = 0.0;//品质退款率
			double rfdSucQaRate_rate = 0.0;//类目同行平均
			double rfdSucRate = 0.0;//退款率
			double rfdSucRate_rate = 0.0;//类目同行平均
			double descScore = 0.0;//描述相符
			double descScore_rate = 0.0;//类目同行平均
			
			Date datetime = new Date();
			Date darCreateDatetime = DateUtil.dateToTimestamp(datetime);
			//创建时间
			int 	darCreateBy = 1;//创建人
			Date darModifyDatetime =  DateUtil.dateToTimestamp(datetime);//修改时间 );
			
			int    darModifyBy	= 1;//修改人
			int    darDel = 0;		 //未删除
			
			if( StringUtil.isBlank(map.get("descScore").toString()) ){
				descScore = 0.0;
			}else if (StringUtil.isBlank(map.get("descScore_rate"))){
				descScore_rate = 0.0;
			}else {
				descScore = Double.parseDouble(map.get("descScore").toString());
				descScore_rate = Double.parseDouble(map.get("descScore_rate").toString());
			}
			
			if( StringUtil.isBlank(map.get("rfdSucRate").toString())){
				rfdSucRate = 0.0;
			}else if (StringUtil.isBlank(map.get("rfdSucRate_rate").toString())){
				rfdSucRate_rate = 0.0;
			}else {
				rfdSucRate = Double.parseDouble(map.get("rfdSucRate").toString());
				rfdSucRate_rate = Double.parseDouble(map.get("rfdSucRate_rate").toString());
			}
			
			if( StringUtil.isBlank(map.get("rfdSucQaRate").toString())){
				rfdSucQaRate = 0.0;
			}else if (StringUtil.isBlank(map.get("rfdSucQaRate_rate").toString())){
				rfdSucQaRate_rate = 0.0;
			}else {
				rfdSucQaRate = Double.parseDouble(map.get("rfdSucQaRate").toString());
				rfdSucQaRate_rate = Double.parseDouble(map.get("rfdSucQaRate_rate").toString());
			}
	 
			String sql = "INSERT INTO `db-mayn-erp-prd`.`dar_guide` ( "
					+ "`DAR_GUIDE_ITEM_ID`,"
					+ "`DAR_GUIDE_DATE`,"
					+ "`DAR_GUIDE_DESC_SCORE`,"
					+ "`DAR_GUIDE_DESC_SCORE_AVG`, "
					+"`DAR_GUIDE_RDFSUCQARATE`, "
					+"`DAR_GUIDE_RDFSUCQARATE_AVG`, "
					+ "`DAR_GUIDE_RFDSUCRATE`, "
					+ "`DAR_GUIDE_RFDSUCRATE_AVG`, "
					+"`DAR_GUIDE_CREATE_DATETIME`,"
					+"`DAR_GUIDE_CREATE_BY`,"
					+"`DAR_GUIDE_MODIFY_DATETIME`,"
					+"`DAR_GUIDE_MODIFY_BY`,"
					+ "`DAR_GUIDE_DEL`)"
					
					+ " VALUES  ('" +  dar_guide_Item_Id
					+ "','"+ darDate
					+ "','"+ descScore
					+ "','"+ descScore_rate
					+ "','"+ rfdSucQaRate
					+ "','"+ rfdSucQaRate_rate
					+ "','"+ rfdSucRate
					+ "','"+ rfdSucRate_rate
					+ "','"+ darCreateDatetime
					+ "','"+ darCreateBy
					+ "','"+ darModifyDatetime
					+ "','"+ darModifyBy
					+ "','"+ darDel
					+ "');";
			
			 LOG.info("保存数据的ID --->:Dar_item_id:"+itemId);
			 LOG.info("保存数据的descScore  --->"+descScore);
			 LOG.info("保存数据的descScore  --->"+descScore_rate);
			 LOG.info("保存数据的descScore  --->"+rfdSucQaRate);
			 LOG.info("保存数据的descScore  --->"+rfdSucQaRate_rate);
			 LOG.info("保存数据的descScore  --->"+rfdSucRate);
			 LOG.info("保存数据的descScore  --->"+rfdSucRate_rate);
			 LOG.info("sql"+sql);
			if( Db.use("erp").update(sql) > 0){
				
				LOG.info("update-->插入成功！");
				return true;
			}else {
				LOG.info("插入失败！");
				return false;
			}
		} catch (Exception e) {
			e.printStackTrace();
			String mailText = "重点服务指标数据抓取失败"+"\r\n"+Thread.currentThread().getStackTrace()[1].getMethodName() + " Exception,Msg=" + e.getMessage();
		    SendCloudMailUtil.sendMailCode(mailText,"service@mayn.com.cn");
		}

		return false;
			
	
	
	}
	}
